import { User, UserProfile } from "@/types/data"
import { profileAction } from "@/types/store"

type ProfileStateType = {
  user: User
  userProfile: UserProfile
}

const initialState: ProfileStateType = {
  user: {} as User,
  userProfile: {} as UserProfile
}

export default function profile(state = initialState, action: profileAction) {
  if (action.type === 'profile/getUser') {
    return {
      ...state,
      user: action.payload
    }
  }
  if (action.type === 'profile/getUserProfile') {
    return {
      ...state,
      userProfile: action.payload
    }
  }

  return state
}